]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
keyboard: Prevent OSK key buttons from creating grabs
authorCarlos Garnacho <carlosg@gnome.org>
Wed, 9 Mar 2022 22:32:30 +0000 (23:32 +0100)
committerMarge Bot <marge-bot@gnome.org>
Sat, 12 Mar 2022 09:28:14 +0000 (09:28 +0000)
In a very un-StButton fashion, OSK keys are not interested in
altering the current focus state, as otherwise pressing those
will trigger a grab that will alter key focus, so the generated
key or IM state events will not be handled by the actor that
originally had the focus as long as the OSK key is pressed.

Despite being StButtons, OSK keys do already perform their own
press/release handling with internal state tracking, so it is
not a big stretch to simply consume the events, and update the
:active pseudo-class manually.

This makes OSK keys still look and behave as usual, but without
any grabbing shenanigans that might affect the focus state. This
makes all OSK keys work again.

Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4986
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2237>

js/ui/keyboard.js

index af195dccfd883457733faab0737de3b1ab57775e..37c71b16b642c85fb886b341e99ed86355a26f85 100644 (file)
@@ -449,11 +449,13 @@ var Key = GObject.registerClass({
         button.keyWidth = 1;
         button.connect('button-press-event', () => {
             this._press(key);
-            return Clutter.EVENT_PROPAGATE;
+            button.add_style_pseudo_class('active');
+            return Clutter.EVENT_STOP;
         });
         button.connect('button-release-event', () => {
             this._release(key);
-            return Clutter.EVENT_PROPAGATE;
+            button.remove_style_pseudo_class('active');
+            return Clutter.EVENT_STOP;
         });
         button.connect('touch-event', (actor, event) => {
             // We only handle touch events here on wayland. On X11
@@ -472,15 +474,18 @@ var Key = GObject.registerClass({
                 event.type() == Clutter.EventType.TOUCH_BEGIN) {
                 this._touchPressSlot = slot;
                 this._press(key);
+                button.add_style_pseudo_class('active');
             } else if (event.type() === Clutter.EventType.TOUCH_END) {
                 if (!this._touchPressSlot ||
-                    this._touchPressSlot === slot)
+                    this._touchPressSlot === slot) {
                     this._release(key);
+                    button.remove_style_pseudo_class('active');
+                }
 
                 if (this._touchPressSlot === slot)
                     this._touchPressSlot = null;
             }
-            return Clutter.EVENT_PROPAGATE;
+            return Clutter.EVENT_STOP;
         });
 
         return button;